package com.xiaoxin.nmzp.server.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.nmzp.JobType;
import com.xiaoxin.nmzp.server.entity.domain.NmzpJob;
import com.xiaoxin.nmzp.server.entity.req.JobReq;
import com.xiaoxin.nmzp.server.entity.vo.JobRecord;
import com.xiaoxin.nmzp.server.entity.vo.NmzpJobVO;
import com.xiaoxin.nmzp.server.service.NmzpJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/nmzp/job")
public class JobController {
    @Autowired
    private JobType jobType;

    @Autowired()
    @Qualifier("jobService")
    private NmzpJobService nmzpJobService;

    @GetMapping("/jobType")
    public AjaxResult getJobType() {
        Map<String, List<JobType.JobTypeItem>> jobMap = jobType.getJobMap();
        return AjaxResult.success(jobMap);
    }

    /**
     * 查询职位列表
     */
    @GetMapping("/list")
    public AjaxResult list(JobReq jobReq) {
        return AjaxResult.success(nmzpJobService.getJobList(jobReq));
    }

    /**
     * 根据ID查询职位
     */
    @GetMapping("/{id}")
    public AjaxResult getJobById(@PathVariable("id") Long jobId) {
        JobReq jobReq = new JobReq();
        jobReq.setJobId(jobId);
        List<NmzpJobVO> jobList = nmzpJobService.getJobList(jobReq);
        return AjaxResult.success(jobList.stream().findFirst());
    }

    /**
     * 查询我的投递记录
     */
    @GetMapping("/delivery")
    public AjaxResult getDeliveryJobList() {
        return AjaxResult.success(nmzpJobService.getDeliveryJobList());
    }
}
